﻿#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

#define GRAY RGB(128, 128, 128)

/*int draw_pie()
{	
	float count = 0;
	const float PI = 3.1415926;

	int x = 300;
	int y = 300;
	int radius = 100;
	int left = x - radius;
	int top = y - radius;
	int right = x + radius;
	int bottom = y + radius;
	float start_angle_1 = 0;
	float end_angle_1 = PI / 6;
	float start_angle_2 = 0;
	float end_angle_2 = PI / 6;

	initgraph(600, 600);
	setbkcolor(WHITE);
	cleardevice();
	
	while (count < 6)
	{
		cleardevice();
		setlinecolor(RED);
		circle(x, y, radius);
		start_angle_1 += 0.1;
		end_angle_1 += 0.1;
		setfillcolor(GREEN);
		solidpie(left, top, right, bottom, start_angle_1, end_angle_1);

		start_angle_2 -= 0.1;
		end_angle_2 -= 0.1;
		setfillcolor(BLUE);
		solidpie(left, top, right, bottom, start_angle_2, end_angle_2);

		Sleep(100);
	}

	_getch();
	closegraph();

	return 0;
}*/


int main()
{
	const float PI = 3.1415926;

	initgraph(1200, 800);
	setbkcolor(GRAY);
	cleardevice();
	srand(time(0));

	float offset = 0;
	float total_offset = 0;

	while (1)
	{
		for (int x = 200; x < 1200; x += 400)
		{
			for (int y = 200; y < 800; y += 400)
			{
				for (int radius = 200; radius > 0; radius -= 50)
				{
					int left = x - radius;
					int top = y - radius;
					int right = x + radius;
					int bottom = y + radius;

					for (int i = 0; i < 20; i++)
					{
						offset = i * PI / 10 + total_offset;
						float h = rand() % 180;
						COLORREF color_1 = HSVtoRGB(h, 0.9, 0.8);
						COLORREF color_2 = HSVtoRGB(h + 180, 0.9, 0.8);
						setfillcolor(color_1);
						solidpie(left, top, right, bottom, offset, 2 * PI / 60 + offset);
						setfillcolor(WHITE);
						solidpie(left, top, right, bottom, 2 * PI / 60 + offset, 3 * PI / 60 + offset);
						setfillcolor(color_2);
						solidpie(left, top, right, bottom, 3 * PI / 60 + offset, 5 * PI / 60 + offset);
						setfillcolor(BLACK);
						solidpie(left, top, right, bottom, 5 * PI / 60 + offset, 6 * PI / 60 + offset);
					}
					total_offset += PI / 20;
				}
			}
		}
	}

	_getch();
	return 0;
}